﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xant.FlowEngine.Core;
using Xant.FlowEngine.Interface;

namespace Xant.FlowEngine.Actor
{
    /// <summary>
    /// 特定职员参与者
    /// <remarks>指定的职员获得参与权</remarks>
    /// </summary>
    public class StaffActor : AbstractActor
    {
        private IStaffMember staffMember;

        public StaffActor(IStaffMember staffMember)
        {
            if (staffMember == null)
                throw new ArgumentNullException();
            this.staffMember = staffMember;
        }

        public override string Text
        {
            get {
                return string.Format("[{0}]{1}", staffMember.Organization.FriendlyName, staffMember.Staff.Name);
            }
        }

        public override string ToXml()
        {
            var xml = string.Format("<Actor Type=\"{0}\" Organization=\"{1}\" Staff=\"{2}\" />", this.Type, staffMember.Organization.Id, staffMember.Staff.Id);
            return xml;
        }

        public override IEnumerable<IStaffMember> GetStaffs()
        {
            return new IStaffMember[] { staffMember };
        }

    }

}
